package com.fosun.spr.core.base.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

import com.alibaba.fastjson.JSONObject;

/**
 * 业务逻辑输出参数基类<BR>
 * 开发者API接口都带有errcode和errmsg的json结果<BR>
 * 参见阿里开发者规范<BR>
 * { "errcode": 0, "errmsg": "ok" }
 * 
 * @author Chen Shiming 陈市明 # SprCore Feb 22, 2017
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class CoBaseSrModel {
	@XmlElement
	private String errcode;
	@XmlElement
	private String errmsg;

	public CoBaseSrModel(String code, String msg) {
		this.errcode = code;
		this.errmsg = msg;
	}

	protected CoBaseSrModel() {
		this.errcode = "0";
		this.errmsg = "ok";
	}

	public String getErrcode() {
		return errcode;
	}

	public void setErrcode(String errcode) {
		this.errcode = errcode;
	}

	public String getErrmsg() {
		return errmsg;
	}

	public void setErrmsg(String errmsg) {
		this.errmsg = errmsg;
	}

	@Override
	public String toString() {
		// return "{\"errcode\":" + errcode + ",\"errmsg\":\"" + errmsg + "\"}";
		return JSONObject.toJSONString(this);
	}
}
